module app.controller.api.SiteController;

import hunt.framework;
import std.json;
import app.response.ResultMsg;
import app.utils.RespCodeEnun;
import app.repository.ProfileRepository;
import app.model.Profile;

class SiteController : Controller
{
    mixin MakeController;

    @Action Response index()
    {
        ResultMsg resultMsg = new ResultMsg;
        ProfileRepository profileRepository = new ProfileRepository();
        Profile profile = profileRepository.findById(1);

        JSONValue item;
        item["avatar"] = profile.avatar;
        item["slogan"] = profile.slogan;
        item["name"] = profile.name;
        item["domain"] = profile.domain;
        item["gitee"] = profile.gitee;
        item["desc"] = profile.desc;
        item["notice"] = profile.notice;
        item["qqchat"] = profile.qqchat;
        item["wechat"] = profile.wechat;
        item["bili"] = profile.bili;
        item["email"] = profile.email;

        // item["avatar"] = "https://s1.ax1x.com/2020/10/11/0cZNdK.jpg";
        // item["slogan"] = "吃得苦中苦    方为人上人";
        // item["name"] = "※听雨※";
        // item["domain"] = "http://47.108.27.128:8080/";
        // item["desc"] = "※听雨※ 的个人博客";
        // item["notice"] = "欢迎访问 ※听雨※ 的个人博客";

        resultMsg.code = RespCodeEnun.SUCCESS;
        resultMsg.msg = "success";
        resultMsg.data["data"] = item;

        return new JsonResponse(resultMsg);
    }
}
